import Vue from "vue";
import VueRouter from "vue-router";
// 解决对此访问下相同路由地址报错问题
const otiginalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return otiginalPush.call(this, location).catch((err) => err);
};

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "login",
    component: () => import("../views/Login.vue"),
  },
  {
    path: "/manage",
    name: "manage",
    component: () => import("../views/manage.vue"),
    children: [
      {
        path: "",
        name: "home",
        component: () => import("../views/home.vue"),
        meta: [],
      },
      {
        path: "/userList",
        name: "userList",
        component: () => import("../views/userList.vue"),
        meta: ["数据管理", "用户列表"],
      },
      {
        path: "/shopList",
        name: "shopList",
        component: () => import("../views/shopList.vue"),
        meta: ["数据管理", "商品列表"],
      },
      {
        path: "/addGoods",
        name: "addGoods",
        component: () => import("../views/addGoods.vue"),
        meta: ["添加数据", "添加商品"],
      },
      {
        path: "/addShop",
        name: "addShop",
        component: () => import('../views/addShop.vue'),
        meta: ['添加数据', '添加商铺']
      },
    ],
  },
];

const router = new VueRouter({
  routes,
});

export default router;
